<?php

/**
 * Created by PhpStorm.
 * User: qiliping
 * Date: 2017/6/16
 * Time: 14:52
 */
class User_share_model extends CI_Model
{
  function get_share_by_school($school_id,$limit = 0,$offset = 10){
    $this->db->trans_start();

    $sql = "SELECT SQL_CALC_FOUND_ROWS us.*,u.nick,u.mobile FROM {$this->db->dbprefix}user_share us left join {$this->db->dbprefix}user u on u.id=us.user_id where us.school_id={$school_id} order by id desc limit $limit,$offset ";
    $result = $this->db->query($sql)->result_array();
    $row_num =  $this->db->query('SELECT FOUND_ROWS() as row_num;')->row_array();

    $this->db->trans_complete();
    return array("total_count" => $row_num['row_num'], "result" => $result);
  }
}
